// 线程礼让  Thread.yield()
//  礼让线程，让当前正在执行的线程暂停，但不阻塞
//  将线程从运行状态转为就绪状态
//  让CPU重新调度，礼让不一定成功，看CPU心情
public class ThreadYieldDemo {
    public static void main(String[] args) {
        MyYield myd = new MyYield();
        new Thread(myd,"A").start();
        new Thread(myd,"B").start();

    }
}
class MyYield implements Runnable{
    @Override
    public void run() {
        System.out.println("Thread " + Thread.currentThread().getName() + " starting...");
        Thread.yield();
        System.out.println("Thread " + Thread.currentThread().getName() + "  finishing...");
    }
}